#define BOOST_TEST_MODULE testElementItemType

#include <boost/test/unit_test.hpp>

#include "common/elements/element_maker.h"
#include "common/elements/item_type.h"

BOOST_AUTO_TEST_CASE(testItemTypeJson)
{
    auto first = std::make_shared<Elements::ItemType>();
    first->setId(1);
    first->setWorkflowId(2);
    first->setDefaultStateId(3);
    first->setCaption("a");
    first->setKind(Elements::ItemType::Kind::Issue);

    const auto json = first->toJsonString();
    const Elements::ElementPtr second(Elements::fromJsonString(json));
    BOOST_CHECK(first->isSame(second.get()));

    const auto third = std::static_pointer_cast<Elements::ItemType>(second);
    BOOST_CHECK(1 == third->id());
    BOOST_CHECK(2 == third->workflowId());
    BOOST_CHECK(3 == third->defaultStateId());
    BOOST_CHECK("a" == third->caption());
    BOOST_CHECK(Elements::ItemType::Kind::Issue == third->kind());
}
